package collection;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: 康大
 * \* Date: 2019/3/4
 * \* Time: 20:22
 * \* To change this template use FileInOut | Settings | FileInOut Templates.
 * \* Description:
 * \
 */
public class Teacher<T> {
	@Test
	public void test1() {
		var list1 = List.of("Java", "Python", "PHP"); // 只读集合
		var copy1 = List.copyOf(list1);
		System.out.println(list1 == copy1); // true

		var list2 = new ArrayList<String>();
		list2.add("Java");
		list2.add("Python");
		list2.add("PHP");
		var copy2 = List.copyOf(list2);
		System.out.println(list2 == copy2); // false

		var list3 = Arrays.asList("Java", "Python", "PHP"); // 只读集合
		var copy3 = List.copyOf(list3);
		System.out.println(list3 == copy3);
		list3.add("1"); // 报 UnsupportedOperationException 异常
	}
}
